﻿package  
{
	import Box2D.Collision.*;
	import Box2D.Dynamics.b2ContactListener;
	import Box2D.Dynamics.Contacts.b2ContactResult;
	
	/**
	 * ...
	 * @author ...
	 */
	public class collisionHandler extends b2ContactListener
	{
		public var m_game:main;
		
		public function collisionHandler(game:main)
		{
			m_game = game;
		}
		
		/// Called when a contact point is added. This includes the geometry
		/// and the forces.
		public override function Add(point:b2ContactPoint):void {
			if ((point.shape1.GetBody().GetUserData() is ball && point.shape2.GetBody().GetUserData() is terrain) ||
			    (point.shape1.GetBody().GetUserData() is terrain && point.shape2.GetBody().GetUserData() is ball))
				{
					m_game.m_gaHandler.m_carCrashed = true;
				}
			
		}
 
		/// Called when a contact point persists. This includes the geometry
		/// and the forces.
		public override function Persist(point:b2ContactPoint):void {
			
		}
 
		/// Called when a contact point is removed. This includes the last
		/// computed geometry and forces.
		public override function Remove(point:b2ContactPoint):void {
			
		}
 
		/// Called after a contact point is solved.
		public override function Result(point:b2ContactResult):void {
		}
	}
	
}